package com.exam.Service;

import com.exam.Entity.FillQuestion;
import com.exam.Mapper.FillQuestionMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FillQuestionService {

    @Autowired
    private FillQuestionMapper fillQuestionMapper;


    public List<FillQuestion> findByIdAndType(Integer paperId) {
        return fillQuestionMapper.findByIdAndType(paperId);
    }


    public List<FillQuestion> findAll(int page,int size) {
        //设置分页参数
        PageHelper.startPage(page, size);
        //执行查询
        List<FillQuestion> result = fillQuestionMapper.findAll();
        // 包装分页结果
        PageInfo<FillQuestion> pageInfo = new PageInfo<>(result);

        return pageInfo.getList();
    }


    public FillQuestion findOnlyQuestionId() {
        return fillQuestionMapper.findOnlyQuestionId();
    }


    public int add(FillQuestion fillQuestion) {
        return fillQuestionMapper.add(fillQuestion);
    }


    public int deleteById(Integer id) {
        return fillQuestionMapper.deleteById(id);
    }

    public List<Integer> findBySubject(String subject, Integer pageNo) {
        return fillQuestionMapper.findBySubject(subject,pageNo);
    }
}
